#pragma once

#include <cstdint>
#include <string>
#include <memory>

#include "session.h"

class player;

class user {
public:
    typedef enum status_e {
        OFFLINE,
        ONLINE,
        MATCHING,
        GAMING,
    } status_t;

    user(const std::string &name = "", uint32_t uid = 0) :
        name_(name),
        uid_(uid)
    {

    }

    void set_uid(uint32_t uid) { uid_ = uid; }
    auto uid() const { return uid_; }

    void set_status(status_t sts) { status_ = sts; }
    auto status() const { return status_; }

    void set_uname(const std::string &name) { name_ = name; }
    auto uname() const { return name_; }

    void set_session(std::shared_ptr<session> session) { session_ = session; }
    std::shared_ptr<session> get_session() const { return session_; } 

    /* get password from database */
    const std::string password() const {
        /* TODO: */
        return "";
    }

    int send(const std::string &msg)
    {
        return session_->send_message(msg);
    }

private:
    uint32_t uid_;
    status_t status_;
    std::string name_;
    std::weak_ptr<player> player_;
    std::shared_ptr<session> session_;
};
